$.ajaxSetup ({cache: false});
var ajax_load = "<img class='loading' src='modules/reequipment/xarimages/ajax-loader.gif' alt='loading...' style='padding-left: 50px; padding-top: 50px;' />";
var update_load = "<img class='loading' src='modules/reequipment/xarimages/ajax-loader.gif' alt='loading...'  /> Creating Order...";
var create_equipment = "<img class='loading' src='modules/reequipment/xarimages/ajax-loader.gif' alt='loading...'  /> Creating Equipment...";

$(document).ready(function(){
    jQuery('#date_expected').calendar();
});

$(document).ready(function(){
    jQuery('#date_returned').calendar();
});


function ApplyToEquipment(item_id){
    var loadUrl = 'index.php?module=reequipment&type=user&func=items&phase=update_inventory&pageName=module';
    $("#invoice_"+item_id).fadeOut('Slow');
    $("#updating").fadeIn().html(update_load).delay("500").fadeOut('slow');
    $.post(
    loadUrl,
    $("#apply_to_equipment_"+item_id).serialize()
    );
}

function CreateInvoice(order_id){
    var loadUrl = 'index.php?module=reequipment&type=user&func=items&phase=create_invoice&pageName=module';
    $("#order_"+order_id).fadeOut('Slow');
    $("#updating").fadeIn().html(update_load).delay("500").fadeOut('slow');
    $.post(
    loadUrl,
    $("#create_invoice_"+order_id).serialize()
    );
}

function CreateEquipment(){
    var loadUrl = 'index.php?module=reequipment&type=user&func=equipment&phase=create&pageName=module';
    $("#equipment_form").fadeOut('Slow');
    $("#creating_equipment").fadeIn().html(update_load).delay("500").fadeOut('slow');
    $.post(
        loadUrl,
        $("#create_equipment").serialize()
    );
    document.getElementById('create_equipment').reset()
    $("#equipment_form").fadeIn('Slow');
}

function CreateInventoryOrder(){
    var loadUrl = 'index.php?module=reequipment&type=user&func=orders&phase=create&pageName=module';
    $("#order_form").fadeOut('Slow');
    $("#creating_order").fadeIn().html(update_load).delay("500").fadeOut('slow');
    $.post(
        loadUrl,
        $("#create_order").serialize()
    );
    document.getElementById('create_order').reset()
    $("#order_form").fadeIn('Slow');
}
